var gulp = require('gulp');
var less = require('gulp-less');
// 调试的时候用
var del = require('del');
var uglify = require('gulp-uglify');
var babel = require('gulp-babel');

// 删除最新编译前的文件
gulp.task('clean:dev', function(done) {
    del(['src/css'], done());
    del(['src/js'], done());
});
// 编译es6
gulp.task('convert:dev', function() {
    return gulp.src('src/es6/*.js')
        // 这里编译规则要用对象
        .pipe(babel({
            "presets": ["@babel/preset-env"]
        }))
        .pipe(gulp.dest('src/js'));
});
// 编译less并压缩导出任务
gulp.task('testless:dev', function(done) {
    gulp.src('src/less/*.less')
        .pipe(less()) //编译less
        .pipe(gulp.dest('src/css')); //导出文件路径
    done();
});
gulp.task('watch', function(done) {
    gulp.watch('src/less/*.less', gulp.series('testless:dev'));
    gulp.watch('src/es6/*.js', gulp.series('convert:dev'));
    done();
});